package com.itzxx.huazhun.ui.record.detail

import com.itzxx.huazhun.data.model.DevicesChildBean
import com.itzxx.huazhun.data.repository.HttpRequestCoroutine
import com.itzxx.library_base_ktx.base.viewmodel.BaseViewModel
import com.itzxx.library_base_ktx.callback.livedata.event.EventLiveData
import com.itzxx.library_base_ktx.ext.request

class RecordDetailViewModel : BaseViewModel() {

    val devicesInfoLiveData = EventLiveData<DevicesChildBean>()

    fun requestDetail(devicesChildBean:DevicesChildBean){
        devicesInfoLiveData.postValue(devicesChildBean)
        request({
            HttpRequestCoroutine.detectionEquipmentInfo(
                devicesChildBean.id,
                devicesChildBean.equipmentNo
            )
        }, {
            devicesInfoLiveData.postValue(it)
        }, {
            toast(it.errorMsg)
        })
    }
}